package la.ge.server.servlets;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import la.ge.server.GeServerContext;

import org.apache.commons.io.IOUtils;

@SuppressWarnings("serial")
public class URLEncodeInputUIServlet extends HttpServlet {
	
	
	/**
	 * request parameters:
	 * String srcString
	 */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
    	GeServerContext geServerContext = (GeServerContext) this.getServletContext().getAttribute( GeServerContext.ATTRIB_NAME );
        response.setContentType("text/html");
        response.setCharacterEncoding( "utf-8" );
        response.setStatus(HttpServletResponse.SC_OK);
       
        InputStream in = URLEncodeInputUIServlet.class.getClassLoader().getResourceAsStream( 
        		"la/ge/server/servlets/URLEncodeInputUIServlet.html" );
        StringWriter stringWriter = new StringWriter();
        IOUtils.copy( in, stringWriter );
        in.close();
        String resp = stringWriter.toString();
        resp = resp.replace("${actionURL}", geServerContext.getServletPath( URLEncodeOutputUIServlet.class ));
        response.getWriter().println( resp );
        
    }
	
}
